package settingsapp.settings.continuous;

import settingsapp.ui.PanelGridActivity;
import android.content.Context;
import android.media.AudioManager;
import ece.settingsapp.R;

public class SettingVolume extends ContinuousSettingChanger
{
	private int audioManagerStream;
	private AudioManager audioManager;
	
	public SettingVolume(PanelGridActivity context, int audioManagerStream, int intRepresentation)
	{
		super(context, intRepresentation);
		this.audioManagerStream = audioManagerStream;
		audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
		min = 0;
		max = audioManager.getStreamMaxVolume(audioManagerStream);
	}
	
	protected void setIntValue(int value)
	{
		audioManager.setStreamVolume(audioManagerStream, value,
				AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI);
	}

	@Override
	public void readValue()
	{
		absoluteValue = audioManager.getStreamVolume(audioManagerStream);
	}

	@Override
	public int getIconResource()
	{
		return R.drawable.volume;
	}
}
